<script>

let p1 = new Promise((resolve,reject) => {
    setTimeout(()=>{reject(1)},1000)
})
let p2 = Promise.reject(2)
let p3 = Promise.resolve(3)



//所有成功才成功，成功值为所有promise的成功值组成的数组
//有一个失败则失败，失败值为失败中最快的那个promise的值
Promise.all([p1,p2,p3]).then(
    values => {console.log("all-resolved",values)},
    reason => {console.log("all-rejected",reason)}
)

//状态为最快的promise的状态，值为此promise的值
Promise.race([p1,p2,p3]).then(
    value => {console.log("race-resolved",value)},
    reason => {console.log("race-rejected",reason)}
)

</script>